{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# 线性回归示例\n",
    "- [熟悉numpy](#熟悉numpy)\n",
    "- [单变量线性回归](#单变量线性回归)\n",
    "- [梯度下降](#梯度下降)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.linear_model.base import LinearRegression\n",
    "from mpl_toolkits.mplot3d import axes3d\n",
    "\n",
    "pd.set_option('display.notebook_repr_html',False)\n",
    "pd.set_option('display.max_columns',None)\n",
    "pd.set_option('display.max_rows',150)\n",
    "pd.set_option('display.max_seq_items', None)\n",
    "\n",
    "import seaborn as sns\n",
    "sns.set_context('notebook')\n",
    "sns.set_style('white')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 熟悉numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def warmUpExercise():\n",
    "    return (np.identity(5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.,  0.,  0.,  0.,  0.],\n       [ 0.,  1.,  0.,  0.,  0.],\n       [ 0.,  0.,  1.,  0.,  0.],\n       [ 0.,  0.,  0.,  1.,  0.],\n       [ 0.,  0.,  0.,  0.,  1.]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "warmUpExercise()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 单变量线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "file_full_path = os.path.join(os.getcwd(), \n",
    "                              '02_第1章_课程讲解案例_Linear-models',\n",
    "                              'linear_regression',\n",
    "                              'linear_regression_data1.txt')\n",
    "\n",
    "data = np.loadtxt(file_full_path, delimiter=',')\n",
    "# data.shape[0] 样本记录数\n",
    "# data[:,0] 所有样本的第1个特征\n",
    "\n",
    "# 在x_1前添加一个x_0,x_0为1，用来匹配系数θ_0\n",
    "X = np.c_[np.ones(data.shape[0]), data[:,0]]\n",
    "y = np.c_[data[:,1]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0,0.5,'Profie in $10,000s')"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEFCAYAAAAPCDf9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3Xu8XFV5//HPIQWiEMELIdLk/FBxP+SnVBFBvHCJgImhVoTa8EtAEhINRSqnWMWmXCtSqRCiaCUIMYgJ8NMYtRgDCOHqhbsEpA8okgRJkFIPBMhBLtM/1t7MPvvMmZlzZvZcv+/Xa14zs2fPzDqTyTNrP3utZ/UUCgVERKQ7bNXsBoiISOMo6IuIdBEFfRGRLqKgLyLSRf6i2Q0ox8y2BfYGNgIvNbk5IiLtYgzwRuB2d38+/UBLB31CwL+52Y0QEWlT+wG3pDfkFvTNbGtgCbArsC1wFrABuAp4KN7tm+5+ZZmX2QiwbNkyJkyYkFdTRUQ6yqZNm5g1axbEMTQtz57+UcCT7n60mb0OuAf4V2Chu59X5Wu8BDBhwgQmTpyYUzNFRDrWkLR4nkH/e8D349s9wIvAXoCZ2UcJvf0+d9+cYxtERCQlt9E77v6Mu282s3GE4H8KcBvwOXffH3gYOD2v9xcRkaFyHbJpZpOANcBl7r4cWOnud8YP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DUDfqTu98O4O7fA3aLax1BSCMQl5jdSBWlrd39acKPxJFm9m+EXvf2ZZ7yQeByd98SB7MlhKAK8Ed3vzu+fR/wusxz9wFuc/dH4vsXpZ47nJcJf3/V4torjxB62ocDP/Hy6zpUavdwSrXr5QqPjXT7T4Cvm9klhDIHy6tsmzSRgr6MVJLTf6e7T3b3Y+J0Q6nvUg9x3p1QoyWxVXy/EO+THDUMElcr/AWwI6H411LKB9lsG3oopjDTtZZeed8qnzucOwhppnSbo7imSjlLCD9mMyldujitUruH8wTwmrguEYSqjY/Ft/9AvDJWnJt/DSE19Mr2zHNKbnf37wPvIhQ07CMc3UmLU9CXenHg9Wa2N4CZ/R2wLpV/TlZjejfhxOZaQt7/bfHjpUa27E0oRHc+IY3yYQb/iGSD8vWE1Mmr4mA2h1Dithq/AvaNRyhBKIRW6bn/DpxuZm8FMLPtCSuNrc/sl23r9wlHERPc/VfkwN1fIBQYnBFv+gTFqpmr4vvEj98c7//KdjP7ADDg7uvj7bPi6q+7EY7qbjezK4F93H0x4STxu/L4W6S+FPSlLuIUxQzC4f59hFKyM1K7vNnCOqAXATPiOu3fBA4ws3uB9zO0nOw1wFZm9htC5dFHgDfFj60GLowXpkjacBVh/dk7gPsJlQ2rGlnkYc3STwErzex+4ECK5wOGe85qwsncK83s14Qe753EJ0NTHgfWm9ma+HlbCEcwl5Ov44FPxZ/ffoSKjhAC9L7x33k88Ol4+wXAtvH2rxFOoEP4kbqfkM77ETA3/hvOBhbE/67nkloCUFqXqmxK7pJRLO5+Q5Ob0nTxmPdxhKB/kLtvanKTpMuopy/SWHsTjlguUsCXZlBPX0Ski6inLyLSRRT0RUS6iIK+iEgXUdAXEekiCvoiIl3kfwHame0Z+nOeZgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x104b95518>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[:,1], y, s=30, c='r', marker='x', linewidths=1)\n",
    "plt.xlim(4,24)\n",
    "plt.xlabel('Population of City in 10000s')\n",
    "plt.ylabel('Profie in $10,000s')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 梯度下降"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算损失函数\n",
    "def computerCost(X, y, theta=[[0],[0]]):\n",
    "    m = y.size\n",
    "    J = 0\n",
    "    \n",
    "    # x与θ点乘得出的预估值\n",
    "    h = X.dot(theta)\n",
    "    J = 1.0 / (2*m)*(np.sum(np.square(h-y)))\n",
    "    return J"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32.072733877455676"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# θ0，θ1都是0时，损失函数会有多大？\n",
    "computerCost(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 梯度下降\n",
    "def gradient_descent(X,y, theta=[[0],[0]], alpha=0.01, num_iters=1500):\n",
    "    m = y.size\n",
    "    J_history= np.zeros(num_iters)\n",
    "    \n",
    "    for iter in np.arange(num_iters):\n",
    "        h = X.dot(theta)\n",
    "        theta = theta - alpha * (1.0/m)*(X.T.dot(h-y))\n",
    "        J_history[iter] = computerCost(X, y, theta)\n",
    "    return theta, J_history"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "theta: [-3.63029144  1.16636235]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Text(0.5,0,'Iterations')"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEFCAYAAADqujDUAAAABHNCSVQICAgIfAhki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qambz8LYWbnTOJe9a2tHvgDP800ifAP79S//XibSBRgMVEclS2gIQEclSKgARkSylAhARyVIqABGRLKUCEBHJUioAEZEspQIQEclS/w+w3DD08/SZTQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10ac93438>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 画出每一次迭代和损失函数变化\n",
    "\n",
    "theta, Cost_J = gradient_descent(X, y)\n",
    "print('theta:', theta.ravel())\n",
    "\n",
    "plt.plot(Cost_J)\n",
    "plt.ylabel('Cost J')\n",
    "plt.xlabel('Iterations')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/seamonster/MachineLearningEngineerEnv/lib/python3.6/site-packages/scipy/linalg/basic.py:1226: RuntimeWarning: internal gelsd driver lwork query error, required iwork dimension not returned. This is likely the result of LAPACK bug 0038, fixed in LAPACK 3.2.2 (released July 21, 2010). Falling back to 'gelss' driver.\n  warnings.warn(mesg, RuntimeWarning)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x10ae56dd8>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEFCAYAAAAPCDf9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzs3Xd4k1X7wPFvOqBAy95LZOSIKA4QnOxlUeQVQV6GgoKgL/7eshwoMkQUVEBQQUTEAYiI+DpYioCAIktZ4kFAoMgehba0pW3O74+nadN0jzRpe3+uK1eTJ8mTOyHcOc95zrmPzRiDEEKI4sHP2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/DjPP/88AQEBOBwO3nzzTUqWLElYWBjGGOLi4pgwYQIhISGMGDGCzz//nM2bNzNjxgxKlixJ+fLlmTx5Mvv37+f9998nMDCQ48ePExoaypNPPpnqs1q8eDGdO3cG4KuvvqJnz57JCR+gY8eOdOjQIc17njVrFi+++CKRkZGcOXOGPn360KdPH7Zv387kyZMpW7Ys/v7+3HzzzRw/fjw5zq1bt6Z5v9988w0bNmwgNjaWY8eOMXjwYO666y6WL19OYGAgTZo0oWnTpskxTZ8+nY0bN1K9enUuXrwIQGRkJC+88ELy7RdffBGlFM8//zxHjx4lNjaWRx55hO7du7Nu3TrefvttjDE0adKECRMmsH379lzHFRQUxJ9//sl1112X+y+tMaZAL3a7vYfdbl+QdP12u92+MpPH1rPb7SY8PNzkydGjxgwZYkxMjHU7JsaYPn2M6ds39bYhQ6zH+rr03k9hib2Q2rJliwkLC0uzvW3btiY2NtY8++yzZvbs2cYYY5YsWWLGjh1rLl68aO69915z5coVY4wxo0aNMps2bTKbN282W7ZsMcYYs2PHDjNgwIDkfe3bty/Na/Tr18+sWbPGGGPMwoULzdSpU40xxly4cMGEhoaahIQE065dO3P27FljjDEjRowwM2fONFu2bDH333+/McYYh8NhOnXqZM6dO2eMMWb69OlmyZIl5tNPPzWvvPKKuXr1qvn555+N1tqsW7fOPP300yYmJsbs2bPHbN++3YSHh5uePXsah8Nh2rZta06dOmWMMWbBggXmtddeM1u2bDH33nuviY+PN9HR0ebWW29N8z4efvhh8/fffxtjjBk7dqz54YcfjDHGxMTEmH79+pl+/fqZ9u3bp3nPe/fuNatXrzbGGHPq1CnTsWNHY4wx9913nzl8+LAxxpiXXnrJzJw5M1Wc6b3fZcuWmccee8wYY8zff/9tOnfubIwxZubMmWbRokWp4t29e7f597//bRITE01kZKS54447THh4uJk6dapZuHBh8j569+5tIiMjTfv27c358+fN+fPnzddff23i4+NN27Ztk2OYO3euOX78eJ7imjVrlvnoo4/SfLbuwsPDjd1uN3a7vZ5xy6veaOkvBzoqpX4Gb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uuuSbV8/z8/HjhhRd44oknMMZQpkwZpk6dSnR0NM8++yyzZ8/G4XDw/PPPU7NmTUaMGMHixYtJSEjgP//5T/J+bDYbkyZN4umnn8Zms1GuXDleffVV/vrrryxjb9GiBbt27aJmzZrUqFGDN954gylTphAdHU1cXBzBwcG8++67aZ7Xtm1bJk2axIoVKwgJCcHf35+rV68yceJEnnnmGYKDgylTpkyqpJ/R+z15Mv0BADfccANTp06lQYMG3H777YB15NaqVSseeughqlatmpxshw4dygsvvMDnn39OVFQUw4YNo0qVKpw9e5bevXvj5+fHY489RokSJRg3bhxDhgzBz8+P66+/nhtvvDFPce3evTvdUWQ54t7f40uXfOvTN8aYPXuMgZTLqVPSDy6KjDlz5pi4uDhjjDEjR440y5cv93JEaR0/ftw8/fTT3g6j0Lp48aIZMmRIth7ra336BS82Frp2Tb3txhut9XFBunhEoVemTBl69epFUFAQtWrVItR9FroPqFWrFkop9uzZw4033ujtcAqdBQsW5L2VD9iMMfkQjmcopeoBf69du5batWvnfkdDh1p9+lWqpCR6sGrrHDiQs7Htx45Z5wicQzRjY1OGaOa2lo4QQuSj48eP0759e4BrtdZHXO8rHi1955j5CRNS18hfsSLnk5nkpLAQohArHkk/o1m5zz6b81msclJYCFGIFf3Syk75tZCJ1L0RQhRixSfp59dCJrL0oRCiECs+ST+/FjKRpQ+LJamymb9VNh0OB6+++ioDBw6kb9++DBo0iPDw8Ayf5/ycn3vuOX766adU982dO5fdu3cTFxfH0qVL0zz3+PHj9OrVK8+xZyUhIYG3336bnj170q9fP/r168eSJUsyjeG5556jefPmqb5D+/btQynFr7/+yrlz55g4cWK+xlk8+vTzkzcKrInU1rwI+/6Xv/ts8gB0mpTjp0mVzexzrbK5YcMGzpw5w4cffgjADz/8wOTJk5k9e3a6z83sc3aWuTh+/DhLly6lZ8+eeYozt6ZPn47D4eCzzz7D39+f6OhohgwZQvPmzSlZsmSGz6tSpQo//fRTcrG5b775hjp16gBWCYoyZcqwdetWWrRokS9xStLPKal7I1xI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gcp+slsaTez/Wa2HziA28c+gfsG/S5pL4Ck94CO8DoCTyMQFrOHacDaWtIEfpO4y8yew3vdS2s0uQ4YkDQZYrYFF1WAnyV9Hd9HgNPL2q4A9kgai+2+QttqTOHX3zDhvTKG97RvB3ap9roO9eKuRqW4pursm235LmCjmb2F2xy822BsyQKSop/MllJO/3JJF0taE+mGSv9LLUTeHfdoKdEa239HndKo4RjCrfBL4DTc/Kuf2iJbHkMLMynMotfS9HkbbFuNfXiaqRjzheGpUost+M3sHipbFxepF3c1fgHawpcI3LXxx/j+A7EyVuTm2/DU0HR5WZuK5ZJ2AJ24oeEj+OguWeSk6CdzhYAzzKwLwMzuBA4V8s+l1ZiW4w82D+J5/0tif6U3W7pwI7pX8DTKjRx7EykX5c/w1MnJIWZrcYvbRhgGVsYbSuBGaPXaPg88ZWYXAJjZUnylsfGyeuWx7sBHEWdLGmYekPQnbjDYE0X3MuOa+XFsE/u/iPrT5WZ2NfCHpPEoXx3urx34qG6vmW0HVkjajD8k7pyPa0nmlhT9ZE6IFEUPPtwfwa1kewpVzjdfB7QP6Amf9jeAa83sAHAV/7aT/QRoNbNvcefRMeC82DcIbIqFKUoxfISvP7sPGMWdDRt6s0i+Zuk64H0zGwVWMfM8oFqbQfxh7nYz+wbv8X5FPAwtcAQYN7PPo90kPoIZYH7pBdbF73cN7ugILtAr4zp7gQej/DVgSZS/ij9AB79JjeLpvA+A++IangXWx9/1RQpLACaLl3TZTOad0lsskoYWOJQFJ955PxUX/esl/bTAISVNRvb0k+T40oWPWPpS8JOFIHv6SZIkTUT29JMkSZqIFP0kSZImIkU/SZKkiUjRT5IkaSJS9JMkSZqIfwD1yhlmnEkHqgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10afdf7b8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "xx = np.arange(5,23)\n",
    "yy = theta[0] + theta[1]*xx\n",
    "\n",
    "# 画出我们自己写的线性回归梯度下降收敛的情况\n",
    "plt.scatter(X[:,1], y, s=30, c='r', marker='x', linewidths=1)\n",
    "plt.plot(xx, yy, label='Linear regression (Gradient descent)')\n",
    "\n",
    "# 和scikit-learn中的线性回归对比一下\n",
    "regr = LinearRegression()\n",
    "# X_train需要是矩阵，y_train需要是向量\n",
    "regr.fit(X[:,1].reshape(-1,1), y.ravel())\n",
    "plt.plot(xx, regr.intercept_ + regr.coef_*xx, label='Linear regression (Scikit-learn GLM)')\n",
    "\n",
    "plt.xlim(4,24)\n",
    "plt.xlabel('Population of City in 10000s')\n",
    "plt.ylabel('Profie in $10,000s')\n",
    "plt.legend(loc=4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 4519.7678677]\n[ 45342.45012945]\n"
     ]
    }
   ],
   "source": [
    "# 预测一下人口为35000和70000的城市的结果\n",
    "print(theta.T.dot([1, 3.5])*10000)\n",
    "print(theta.T.dot([1, 7])*10000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
